<!--中间的表单设置-->
<template>
  <div>
    <a-form
      ref="form"
      :model="modelSetUpList"
      autoLabelWidth
      :layout="(layout as Tlayout)"
    >
      <a-row :gutter="16">
        <a-col
          v-for="(item, index) in modelSetUpList"
          :key="index"
          :span="item.span"
        >
          <FormItem :data="item" :review="review" />
        </a-col>
      </a-row>
    </a-form>
  </div>
</template>
<script setup lang="ts">
import FormItem from '../FormItem/index.vue';
import useControlFormStore from '@/store/controlForm';
// eslint-disable-next-line @typescript-eslint/no-unused-vars
type Tlayout = 'inline' | 'horizontal' | 'vertical' | undefined;
import { useVModel } from '@vueuse/core';

const props = withDefaults(
  //参数说明
  defineProps<{
    setUpList: any[]; //tab显示的tab列表
    layout: string; //a-form的layout参数,
    //正则库
    regex?: {
      [name: string]: {
        role: any;
        name: any;
      };
    };
    review?: boolean;
  }>(),
  {
    review: false
  }
);
const emits = defineEmits(['update:setUpList']);
const modelSetUpList = useVModel(props, 'setUpList', emits);
const controlFormStore = useControlFormStore();
const regexList = ['TEXT']; //可以传递正则库的控件类型列表，避免内存泄漏

const form = ref();

//表单校验函数
const validate = async () => {
  const res = await form.value.validate();
  if (res) return Promise.resolve();
  return Promise.reject();
};
defineExpose({ validate }); //抛出导航函数
</script>
<style lang="less" scoped></style>
